package com.sjz.bookmark.mysql;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.treeStructure.Tree;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.ArrayList;


public class BookmarkWindowFactory implements ToolWindowFactory {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        // 创建树形结构
        DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode("Bookmarks"));
        Tree tree = new Tree(treeModel);


        // 添加示例数据
        addSampleData(new DefaultMutableTreeNode(treeModel.getRoot()));

        // 创建滚动面板并添加到工具窗口
        JScrollPane scrollPane = new JScrollPane(tree);
        scrollPane.setPreferredSize(new Dimension(200, 300));
        toolWindow.getComponent().add(scrollPane);
    }

    private void addSampleData(DefaultMutableTreeNode root) {
        // 从数据库重新加载数据

    }
}